Skip to content

refactor: do not override Exception's $code in RedirectException - #10465

Open
paulbalandan wants to merge 2 commits into
codeigniter4:4.8from
paulbalandan:redirect-exception-status-code
Open

refactor: do not override Exception's $code in RedirectException#10465
paulbalandan wants to merge 2 commits into
codeigniter4:4.8from
paulbalandan:redirect-exception-status-code

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description
RedirectException redeclares the $code property from the base Exception. It is untyped, so we cannot natively declare an int type as it would fatal, nor add a phpdoc as phpstan will complain you're narrowing an invariant property. Moreover, the $code property is used here as the HTTP status code not the exception code. Thus, this PR proposes uses another property for the status code.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan added refactor Pull requests that refactor code breaking change Pull requests that may break existing functionalities labels Aug 16, 2026
@paulbalandan
paulbalandan force-pushed the redirect-exception-status-code branch from bd18ac0 to 0dadf42 Compare August 16, 2026 19:06
@github-actions github-actions Bot added the 4.8 PRs that target the `4.8` branch. label Aug 16, 2026
@paulbalandan paulbalandan changed the title refactor: do nor override Exception's $code in RedirectException refactor: do not override Exception's $code in RedirectException Aug 16, 2026
@paulbalandan
paulbalandan requested a balanced review from Copilot August 16, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors RedirectException to separate HTTP redirect status from the inherited exception code. Assessed as targeting the 4.8 minor line.

Changes:

  • Adds $defaultStatusCode for response redirects.
  • Removes the resolved PHPStan baseline error.
  • Documents the compatibility change.

Validation: Static review only; automated validation left to CI.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
system/HTTP/Exceptions/RedirectException.php Introduces the dedicated redirect status property.
utils/phpstan-baseline/property.phpDocType.neon Removes the resolved property-type error.
utils/phpstan-baseline/loader.neon Updates the total baseline count.
user_guide_src/source/changelogs/v4.8.0.rst Records the breaking extension-point change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread system/HTTP/Exceptions/RedirectException.php
Comment thread user_guide_src/source/changelogs/v4.8.0.rst Outdated
Comment thread system/HTTP/Exceptions/RedirectException.php Outdated
Comment thread user_guide_src/source/changelogs/v4.8.0.rst Outdated
@github-actions github-actions Bot added the stale Pull requests with conflicts label Aug 18, 2026
@github-actions

This comment was marked as outdated.

@paulbalandan
paulbalandan force-pushed the redirect-exception-status-code branch from 0dadf42 to 594b20f Compare August 23, 2026 12:36
@paulbalandan paulbalandan removed the stale Pull requests with conflicts label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. breaking change Pull requests that may break existing functionalities refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants